<?PHP
	$templatePath= get_absolute_template_path(); 
	
	$settings=array();
	
	if( isset($_POST['youtube']) && isset($_POST['youtubeHref']))
	{
		$settings=	 json_decode(file_get_contents($templatePath."/settings.txt"));
		$settings->youtube= $_POST['youtube'];
		$settings->youtubeHref= $_POST['youtubeHref'];
		
		file_put_contents($templatePath."/settings.txt", json_encode($settings));
	}
	else
		$settings= json_decode(file_get_contents($templatePath."/settings.txt"));
	
?>
<h1>Set youtube video id</h1>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
	<label for="youtube">http://www.youtube.com/watch?v=</label>
	<input type="text" size="20" maxlength="250" onclick="select();"  name="youtube" style="display:inline" />
	<input class="button button-primary" type="submit" name="upload_title_image" value="Save value" style="display:inline" />
	<br />
	<br />
	<br/>

	<label for="youtube">Youtube video:</label>
	<br/>
	<input type="hidden" value="1" size="20" maxlength="250" onclick="select();" name="youtubeHref" style="display:inline" />
	<iframe width="300" height="250" src="http://www.youtube.com/embed/<?PHP echo $settings->youtube; ?>" frameborder="0" allowfullscreen></iframe>
	</a>
</form>